/***************************************************************************
 *            object_3d.h
 *
 *  Mon Aug 25 17:40:40 2008
 *  Copyright  2008  Tiago Falcão
 *  <tiago@tiagofalcao.com>
 ****************************************************************************/

/*
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Library General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
 */
 
#ifndef OBJECT_3D_H
#define OBJECT_3D_H

#include "points.h"
#include "matrix.h"
#include <GL/gl.h>
#include <GL/glut.h>
#include "bool.h"

#define OBJ3D_MODE_DEFAULT 0x00
#define OBJ3D_MODE_SELECTED 0x01
#define OBJ3D_MODE_WIRE 0x02
#define OBJ3D_MODE_FILL 0x04
#define OBJ3D_MODE_SMOOTH 0x08
#define OBJ3D_MODE_FACE 0x10

typedef struct color{
float r,g,b,a;
} color_t;

typedef struct object{
	unsigned int mode;					// Indica o modo de visualizacao
	GLuint texture;						// Textura
	GLfloat color[4];						// Cor do Objeto
	
	GLfloat * matrix;					// Matriz de Transformacao,modelo OpenGL
	
	GLfloat ambient[4];					// Reflexao da Luz Ambiente
	GLfloat diffuse[4];					// Reflexao da Luz Difusa
	GLfloat specular[4];				// Reflexao da Luz Especular
	GLfloat shininess;					// Concentracao da Reflexao
	GLfloat emission[4];				// Reflexao da Luz Emissiva
	
	void * object;						// Dados do Objeto
	void (*display)(void *,bool,GLuint);// Funcao de Desenho do Objeto
	void (*object_delete)(void *);		 // Funcao de Delete

} object;

// Cria Objeto 3D
object * object_create(void (*display)(void *,bool,GLuint), void * object,void (*object_delete)(void *));

//Libera Objeto 3D
void object_delete(object * obj);

// Desenha Objeto 3D
void object_display(object * obj);
void object_display_mode(object * o);

//Translacao em X
void object_trans_x(object * obj,short int sign);
//Translacao em Y
void object_trans_y(object * obj,short int sign);
//Translacao em Z
void object_trans_z(object * obj,short int sign);

//Rotacao no eixo X
void object_rot_x(object * obj,short int sign);
//Rotacao no eixo Y
void object_rot_y(object * obj,short int sign);
//Rotacao no eixo Z
void object_rot_z(object * obj,short int sign);

//Tamanho
void object_size(object * obj,short int sign);

//Escala em X
void object_scale_x(object * obj,short int sign);
//Escala em Y
void object_scale_y(object * obj,short int sign);
//Escala em Z
void object_scale_z(object * obj,short int sign);

//Seta Cor do Objeto
void object_set_color(object * obj,GLfloat r, GLfloat g, GLfloat b, GLfloat a);

//Seta Ambiente
void object_set_ambient(object * obj,GLfloat r, GLfloat g, GLfloat b, GLfloat a);

//Seta Difusa
void object_set_diffuse(object * obj,GLfloat r, GLfloat g, GLfloat b, GLfloat a);

//Seta Especular
void object_set_specular(object * obj,GLfloat r, GLfloat g, GLfloat b, GLfloat a);

//Seta Emissao
void object_set_emission(object * obj,GLfloat r, GLfloat g, GLfloat b, GLfloat a);

//Seta Brilho
void object_set_shininess(object * obj,GLfloat shininess);

#endif /* OBJECT_3D_H */

